#pragma once

#include "Game/Process/RenderProcess.h"
#include "Render/Texture/Picture2DTexture.h"
#include "Render/Texture/RenderTarget.h"
#include "Render/Tradition/RHIRenderPass.h"
#include "Render/Tradition/GraphicsPipeline.h"
#include "Render/Texture/ColorRenderTarget.h"
#include "Render/Texture/CubemapTexture.h"
#include "Render/Texture/DepthRenderTarget.h"
#include "Render/Shader/RHIDescriptor.h"
#include "Render/Tradition/RHIFramebuffer.h"
#include "LocalEntity.h"
#include "Render/Tradition/RHIFence.h"

class LocalScene;

class VoxelProcess : public RenderProcess
{
	DECLARE_PROCESS(VoxelProcess)

	struct LocalVertex
	{
		glm::vec3 position;
		glm::vec2 uv;
	};

	struct PushConstants
	{
		uint32 voxelResolution;
		uint32 countOnly;
		uint32 hasTexture;
		uint32 albedo;
	};

protected:

	virtual void OnInit() override;

	virtual void OnTick(float deltaTime) override;

	virtual void OnResize() override;

public:

	uint32 mVoxelFragmentCount;

	uint32 mVoxelResolution;

protected:

	LocalScene* mLocalScene;

	LocalEntity* mSceneEntity;

	int32 mObjectSize;

	VkViewport mViewport;

	VkRect2D mScissor;

	std::vector<PushConstants> mPushConstants;



	RefCountPtr<RHITexture> mEmptyImage;

	RefCountPtr<RHISampler> mEmptySampler;



	RefCountPtr<RHIBuffer> mCounterBuffer;

	RefCountPtr<RHIBuffer> mFragmentListBuffer;



	RefCountPtr<RHIDescriptor> mDescriptor;

	RefCountPtr<GraphicsPipeline> mPipeline;

	RefCountPtr<RHIRenderPass> mRenderPass;

	RefCountPtr<RHIFrameBuffer> mFrameBuffer;

	RefCountPtr<RHICommandBuffer> mCounterCommandBuffer;

	RefCountPtr<RHICommandBuffer> mFragmentCommandBuffer;

	RefCountPtr<RHIFence> mCounterFence;

	RefCountPtr<RHIFence> mFragmentFence;

};
